package com.lagou.springboot.controller;

import com.github.pagehelper.PageInfo;
import com.lagou.springboot.pojo.Article;
import com.lagou.springboot.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private IndexService indexService;

    @RequestMapping("/index")
    public String index(Model model,Integer pageNum){
        PageInfo<Article> articles = indexService.articleList(pageNum);
        model.addAttribute("articleList",articles);
        return "index";
    }
}
